﻿using BO.News;
using GUI.Extensions;

namespace GUI.Controls.News
{
    public partial class EmbedGroup1 : System.Web.UI.UserControl
    {
        private const int ImageWidth = 140;
        private const int ImageHeight = 105;

        public void DataBind(int zoneId1, int zoneId2)
        {
            var bo = CacheSettingExtensions.EnableCacheHtml
                         ? NewsBO_NoCache.GetInstance()
                         : NewsBO.GetInstance();
            if (zoneId1 > 0)
            {
                var category = NewsBO.GetInstance().GetCategoryDetail(zoneId1);
                if (category != null)
                {
                    var listNews = bo.ImportNewsWhileNotEnough(zoneId1, 4, 0);
                    ctrNewsZone1.DataBind(category, listNews, ImageWidth, ImageHeight);
                }
            }
            if (zoneId2 > 0)
            {
                var category = NewsBO.GetInstance().GetCategoryDetail(zoneId2);
                if (category != null)
                {
                    var listNews = bo.ImportNewsWhileNotEnough(zoneId2, 4, 0);
                    ctrNewsZone2.DataBind(category, listNews, ImageWidth, ImageHeight);
                }
            }

        }


    }
}